Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@okta/okta-auth-js

Package Overview
Dependencies
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okta/okta-auth-js

The Okta Auth SDK

  • 1.17.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
399K
decreased by-14.23%
Maintainers
1
Weekly downloads
 
Created

What is @okta/okta-auth-js?

@okta/okta-auth-js is a JavaScript library that provides a set of tools for integrating Okta's authentication and authorization services into your web applications. It allows you to handle user authentication, manage tokens, and interact with Okta's APIs.

What are @okta/okta-auth-js's main functionalities?

User Authentication

This feature allows you to authenticate users by their username and password. The code sample demonstrates how to sign in a user and handle the authentication transaction.

const OktaAuth = require('@okta/okta-auth-js');
const authClient = new OktaAuth({
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  clientId: '{clientId}',
  redirectUri: 'http://localhost:8080/login/callback'
});

async function signIn(username, password) {
  try {
    const transaction = await authClient.signIn({ username, password });
    if (transaction.status === 'SUCCESS') {
      authClient.token.getWithRedirect({
        sessionToken: transaction.sessionToken
      });
    } else {
      throw new Error('We cannot handle the ' + transaction.status + ' status');
    }
  } catch (err) {
    console.error(err);
  }
}

Token Management

This feature allows you to manage tokens, including obtaining tokens without prompting the user. The code sample demonstrates how to get an ID token using the OktaAuth client.

const OktaAuth = require('@okta/okta-auth-js');
const authClient = new OktaAuth({
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  clientId: '{clientId}',
  redirectUri: 'http://localhost:8080/login/callback'
});

async function getToken() {
  try {
    const token = await authClient.token.getWithoutPrompt({
      responseType: 'id_token',
      scopes: ['openid', 'profile', 'email']
    });
    console.log(token);
  } catch (err) {
    console.error(err);
  }
}

Session Management

This feature allows you to manage user sessions. The code sample demonstrates how to check the current session using the OktaAuth client.

const OktaAuth = require('@okta/okta-auth-js');
const authClient = new OktaAuth({
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  clientId: '{clientId}',
  redirectUri: 'http://localhost:8080/login/callback'
});

async function checkSession() {
  try {
    const session = await authClient.session.get();
    console.log(session);
  } catch (err) {
    console.error(err);
  }
}

Other packages similar to @okta/okta-auth-js

Keywords

FAQs

Package last updated on 26 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc